@using MduiBlazor.Shared.Data

<MduiTableContainer>
    <MduiTable MultiSelection Items="@datas" TreeChildren="c=>c.Children">
        <Columns>
            <MduiColumn TreeField Title="Title">@context.Title</MduiColumn>
            <MduiColumn Title="Level">@context.Level</MduiColumn>
        </Columns>
    </MduiTable>
</MduiTableContainer>

@code {
    private IEnumerable<TreeData> datas = [
        new TreeData{Title="1", Children=[
            new TreeData{Title="1.1", Level=1, Children=[
                new TreeData{Title="1.1.1", Level=2},
                new TreeData{Title="1.1.2", Level=2}
        ]},
            new TreeData{Title="1.2", Level=1}
        ]},
        new TreeData{Title="2", Children=[
            new TreeData{Title="2.1", Level=1},
            new TreeData{Title="2.2", Level=1}
    ]}];

    private class TreeData
    {
        public string? Title { get; set; }

        public int Level { get; set; }

        public IEnumerable<TreeData> Children { get; set; } = [];
    }
}